package com.free.mini.admin.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.free.mini.common.base.ResultData;
import com.free.mini.core.server.api.StudyQuestionApi;
import com.free.mini.core.server.vo.req.StudyQuestionCreateReqVO;
import com.free.mini.core.server.vo.req.StudyQuestionListQueryReqVO;
import com.free.mini.core.server.vo.req.StudyQuestionQueryDetailReqVO;
import com.free.mini.core.server.vo.req.StudyQuestionUpdateReqVO;
import com.free.mini.core.server.vo.resp.StudyQuestionListQueryRespVO;
import com.free.mini.core.server.vo.resp.StudyQuestionQueryDetailRespVO;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author dongsufeng
 * @version 4.0
 * @date 2023/8/22 08:50
 */
@RestController
@RequestMapping("api/admin/question/v1/")
@Slf4j
@RequiredArgsConstructor
public class AdminQuestionController {

    private final StudyQuestionApi studyQuestionApi;
    /**
     * 录入题目
     * @param reqVO
     * @return
     */
    @PostMapping("/create")
    public ResultData<Boolean> create(@RequestBody @Validated StudyQuestionCreateReqVO reqVO){
        return studyQuestionApi.create(reqVO);
    }
    /**
     * 查询题目列表
     */
    @PostMapping("/list")
    public ResultData<Page<StudyQuestionListQueryRespVO>> list(@RequestBody @Validated StudyQuestionListQueryReqVO reqVO){
        return studyQuestionApi.list(reqVO);
    }

    @PostMapping("/detail")
    public ResultData<StudyQuestionQueryDetailRespVO> detail(@RequestBody @Validated StudyQuestionQueryDetailReqVO reqVO){
        return studyQuestionApi.detail(reqVO);
    }

    /**
     * 修改题目
     * @param reqVO
     * @return
     */
    @PostMapping("/update")
    public ResultData<Boolean> update(@RequestBody @Validated StudyQuestionUpdateReqVO reqVO){
        return studyQuestionApi.update(reqVO);
    }
}
